document.addEventListener('DOMContentLoaded', function(){
    var likesbtn = document.getElementById('like-btn')
    var likes = document.getElementById('likeTotal')

    likesbtn.addEventListener('click', function(){
        fetch(
            '/images/likes/' + likesbtn.dataset.imageid,
            {method: 'POST', body: {}}    
        ).then(response => response.json())
        .then(resp => {
            console.log(resp)
            likesbtn.innerHTML = " " + resp.doc.likes
            likes.innerHTML = " " + resp.info.numOfLikes
        })
    })
}) 